//
//  ZH_ViedoInfomationViewController.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/11/12.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_ViedoInfomationViewController.h"
#import <TXLiteAVSDK_Smart/TXLiveBase.h>
#import <TXLiteAVSDK_Smart/TXLivePlayer.h>
#import <TXLiteAVSDK_Smart/TXVodPlayer.h>
#import <TXLiteAVSDK_Smart/TXLivePlayConfig.h>
#import <TXLiteAVSDK_Smart/TXLivePlayListener.h>
#import "ZH_ClassViewModel.h"
@interface ZH_ViedoInfomationViewController ()<TXLivePlayListener,TXVodPlayListener>
/*播放view */
@property (nonatomic,strong) UIView *playerView;
/* 直播播放器*/
@property (nonatomic,strong)TXLivePlayer *livePlayer;
/*播放器的设置 */
@property (nonatomic,strong) TXLivePlayConfig *config;
//viewModel
@property (nonatomic,strong)ZH_ClassViewModel *viewModel;
@end

@implementation ZH_ViedoInfomationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUserInterface];
    [self getupLiveDeatilData];
    
}
- (void)cleanUpData{
    [self setViewModel:nil];
}
- (void)dealloc{
    [_livePlayer removeVideoWidget];
    [_livePlayer stopPlay];
}
- (void)initUserInterface{
    self.navigationItem.title = self.nameString;
    self.view.backgroundColor = kCommonWhiteBg;
    [self.playerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.height.mas_equalTo(FITSCALE(229));
    }];
}
#pragma mark -- 获取直播详情数据
-(void)getupLiveDeatilData{
    WEAKSelf;
    [self.viewModel courseDetailResultBlock:^(NSString *code, NSString *message, id data) {
        
    }];
}
#pragma mark - getter,setter
-(TXLivePlayer *)livePlayer{
    if (_livePlayer == nil) {
        _livePlayer = [[TXLivePlayer alloc]init];
        [_livePlayer setupVideoWidget:CGRectMake(0, 0, 0, 0) containView:self.playerView insertIndex:0];
        _livePlayer.delegate = self;
        [_livePlayer setRenderMode:RENDER_MODE_FILL_SCREEN];
        [_livePlayer setConfig:_config];
        
    }
    return _livePlayer;
}
-(TXLivePlayConfig *)config{
    if (_config == nil) {
        _config = [[TXLivePlayConfig alloc]init];
        _config.enableMessage = YES;
    }
    return _config;
}
- (UIView *)playerView{
    if (!_playerView) {
        UIView *view = [UIView createViewWithBackgroundColor:kFontColorWhite];
        [self.view addSubview:_playerView = view];
    }
    return _playerView;
}
- (ZH_ClassViewModel *)viewModel{
    if (!_viewModel) {
        _viewModel = [[ZH_ClassViewModel alloc] init];
    }
    return _viewModel;
}
@end
